﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;

namespace ProductFileDbAccessLayer
{
    public class DbApplContext
    {
        private ProductFileDBEntities m_DbContext = null;
        private static volatile DbApplContext s_Instance = null;
        private static object s_InstanceLockObj = new Object();

        private DbApplContext() 
        {
            m_DbContext = new ProductFileDBEntities();
        }

        public static DbApplContext Instance
        {
            get
            {
                if (s_Instance == null)
                {
                    lock (s_InstanceLockObj)
                    {
                        if (s_Instance == null)
                        {
                            s_Instance = new DbApplContext();
                        }
                    }
                }

                return s_Instance;
            }
        }

        #region Users
        
        public User GetUser(string userName, string passWord)
        {
            User user = null;
            user = m_DbContext.Users.SingleOrDefault(p => p.Password == passWord && p.UserName == userName);
            return user;
        }


        #endregion 

    }
}
